<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<link rel="stylesheet" th:href="@{/css/admin.css}" media="all" />
<link rel="stylesheet" th:href="@{/plugins/zTree/css/zTreeStyle/zTreeStyle.css}" media="all" />
<body>
<input id="treeId"   name="treeId"    type="hidden" th:value="${menu.menuId}"/>
<input id="treeName" name="treeName"  type="hidden" th:value="${menu.menuName}"/>
<div style="height: 350px;overflow-y: auto;overflow-x: hidden;">
    <ul id="tree" class="ztree" style="padding: 20px 0px 20px 40px;"></ul>
</div>

<!--<div class="text-right" style="padding-top: 10px;padding-right: 25px;">
    <button class="layui-btn layui-btn-primary" ew-event="closeDialog">取消</button>
    <button id="btnSave" class="layui-btn">保存</button>
</div>-->

<!-- js部分 -->
<div th:include="include::footer"></div>
<script type="text/javascript" th:src="@{/plugins/zTree/js/jquery.ztree.all-3.5.min.js}"></script>
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<script>
    layui.use(['layer','admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var url = ctx + "system/menu/menuTreeData";
        layer.load(2);
        var setting = {
            check: {enable: false},
            view: { selectedMulti: false, nameIsHTML: true },
            data: {
                simpleData: {enable: true}
            },
            callback: { onClick: zOnClick }
        };
        $.get(url, {}, function (data) {
            var treeName = $("#treeName").val();
            var treeId = $("#treeId").val();
            $._tree = tree;
            $.fn.zTree.init($('#tree'), setting, data);
            layer.closeAll('loading');
        }, 'json');


        function zOnClick(event, treeId, treeNode) {
          var treeId = treeNode.id;
            var treeName = treeNode.name;
            $("#treeId").val(treeId);
            $("#treeName").val(treeName);
        }
        // 保存按钮点击事件
  /*      $('#btnSave').click(function () {
            var treeObj = $.fn.zTree.getZTreeObj('tree');
            var nodes = treeObj.getCheckedNodes(true);
            // 关闭当前iframe弹出层
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });*/

    });
</script>

</body>
</html>